import java.util.Scanner;

public class ToyPurchase{

	static void insertionSort(int[] toys){	

		for(int i = 1; i < toys.length; i++){
			
			int value = toys[i];
			int j = i -1;
			
			while (	j 	>=	0 &&	toys[j]		>		value)	{
					
					toys[j	+	1]	=	toys[j];
					j--;
			}
			
			toys[j	+	1]	=	value;
		}
	}

	public static void printArray(int[] arr){

		for(int i = 0; i < arr.length ; i++){
			System.out.print(arr[i]+  " ");
		}
		System.out.println();
	}

	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		
		String line = input.nextLine();
		
		String[] inputs = line.split(" ");
		
		int n = Integer.parseInt(inputs[0]), k =Integer.parseInt(inputs[1]);
		
		line	=	input.nextLine();
		inputs = line.split(" ");
		
		int[] toys = new int[n];
		
		for(int i =0; i < n ; i++)	{
			toys[i]	= 	Integer.parseInt(inputs[i]);
		}
		
		insertionSort(toys);
		
		int index = findIndexForPurchase(toys,k);
		
		//for(int i = 0; i <	index; i++ )	{
			//System.out.print(toys[i] + " " );
		//}
		System.out.println(index);
		input.close();
	}
	
	public static int findIndexForPurchase(int[] toys	,	int amt){
		
		int sum =0;
		int index =0;
		while(	sum		<=	amt	)	{
			sum	+= toys[index];
			index++;
		}
		if	(index > 0){
			index --;
		}
		return index;
	}
}